package com.hxx.config;

import dev.langchain4j.model.chat.listener.ChatModelErrorContext;
import dev.langchain4j.model.chat.listener.ChatModelListener;
import dev.langchain4j.model.chat.listener.ChatModelRequestContext;
import dev.langchain4j.model.chat.listener.ChatModelResponseContext;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class TestChatModelListener implements ChatModelListener {

    @Override
    public void onRequest(ChatModelRequestContext requestContext) {
        ChatModelListener.super.onRequest(requestContext);
        requestContext.attributes().put("hxx","请求");
    }

    @Override
    public void onResponse(ChatModelResponseContext responseContext) {
        ChatModelListener.super.onResponse(responseContext);
        Object data = responseContext.attributes().get("hxx");
        log.info("hxx:{}",data);
    }

    @Override
    public void onError(ChatModelErrorContext errorContext) {
        ChatModelListener.super.onError(errorContext);
    }
}
